import os, re

# deprecated
SVN_PATTERN = '[a-z\-]+_(\d+)\.(\d+)\-SVN(\d+).*'
# deprecated
SIMPLE_PATTERN = '\d+'

def parse_numbers(s):
	return map(int, re.findall('\d+', s))

def get_last_package(
    targetdir='dist',
    pattern=SVN_PATTERN #deprecated
):
    """
    Gets last (with most recent version) deb package file from directory
    @return str
    """
    filelist = os.listdir(targetdir)
    packages = [f for f in filelist if f.endswith('.deb')]
    packages.sort(key=parse_numbers, reverse=True)
    print "Found most recent package: %s out of sorted: %s" % (packages[0], packages)
    return packages[0]
